﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Org.BouncyCastle.Asn1;
using System.IO;

namespace TheClerk.Forms.Templates.raw.Envelope
{
    #region public CopyrightLicense
    // TODO: Completely redo copyright clauses
    /// <summary>
    /// Container for CopyrightLicense info (self-contained)
    /// </summary>
    /// CopyrightLicense ::= SEQUENCE(0..MAX) OF LicenseClause
    /// LicenseClause ::= SEQUENCE {
    ///     parsableCopyrightTerm OBJECT IDENTIFIER ,
    ///     languageOfControl UTF8String,
    ///     legibleCopyrightText LegibleClauses OPTIONAL }
    /// LegibleClauses ::= SEQUENCE(0..MAX) OF LegibleClause
    /// LegibleClause ::= SEQUENCE {
    ///     languageCode UTF8String,
    ///     textOfLicense UTF8String }
    
    // TODO: NotImplemented
    public class CopyrightLicense : Assertion
    {
        List<LicenseClause> licenseclauses = new List<LicenseClause>();
        
        //HACK
        public CopyrightLicense() : base()
        {
            var StringThisIsSuchAHack = @"Copyright notice and license grant placeholder";
            var ArrayThisIsSuchAHack = StringThisIsSuchAHack.ToArray();
            var encoding = System.Text.UTF8Encoding.UTF8.GetEncoder();
            byte[] mybytearray = new byte[encoding.GetByteCount(ArrayThisIsSuchAHack,0,StringThisIsSuchAHack.Length,true)];
            encoding.GetBytes(ArrayThisIsSuchAHack,0,ArrayThisIsSuchAHack.Length,mybytearray,0,true);
            SetContent(new MemoryStream(mybytearray));
            SetType(new AssertionType("application/envelope-copyright"));
        }
    }
    #endregion
}
